/*
 * 通讯录页面
 * */
import React, { Component } from 'react';
import {
    StyleSheet,
    TouchableHighlight,
    Navigator,
    Text,
    View
} from 'react-native';

import RefreshAndInfiniteList from '../components/RefreshAndInfiniteList';


export default class MailList extends Component {
    listViewOnRefresh=(page = 1, callback, options)=> {
        setTimeout(() => {
            var rows = ['row '+((page - 1) * 3 + 1), 'row '+((page - 1) * 3 + 2), 'row '+((page - 1) * 3 + 3)];
            if (page === 8) {
                callback(rows, {
                    allLoaded: true, // the end of the list is reached
                });
            } else {
                callback(rows);
            }
        }, 1000); // simulating network fetching
    }
    render() {
        return (
            <RefreshAndInfiniteList
                renderRow={(rowData)=><Text style={{height:80}}>{rowData}</Text>}
                renderHeader={()=> <View style={{height:30,borderBottomWidth:2,marginTop:5,marginBottom:5,borderRadius:20,backgroundColor: 'white',flex:1,width:200,alignItems:'center', justifyContent:'center'}}>
                               <Text style={{color:'#a9a9a9'}}>请输入关键词</Text>
                           </View>}
                onRefresh={(page, callback)=>this.listViewOnRefresh(page, callback)}
                backgroundColor={'#F6F6EF'}
                loadMoreText={'Load More...'}
            />

        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    }
});

